package top.abrsm.service.impl;

import top.abrsm.entity.CommentEntity;
import top.abrsm.mapper.CommentMapper;
import top.abrsm.service.ICommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.abrsm.util.StateEnum;
import top.abrsm.util.StateException;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 商品评论表 服务实现类
 * </p>
 *
 * @author WuZH
 * @since 2023-11-18
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentEntity> implements ICommentService {

    @Resource
    private CommentMapper commentMapper;

    @Override
    public List<CommentEntity> queryList ( CommentEntity commentEntity) {
        if ( commentEntity == null ) {
            throw new StateException ( StateEnum.REQUEST_PARAM_EXCE );
        }
        List<CommentEntity> commentEntities = commentMapper.queryList ( commentEntity.getOrderId (), commentEntity.getStuId (), commentEntity.getProductId (), commentEntity.getProductScore (), ( commentEntity.getPageNum () - 1 ) * commentEntity.getPageSize (), commentEntity.getPageSize () );
        return commentEntities;
    }


    @Override
    public Integer queryCount (CommentEntity commentEntity) {
        Integer integer = commentMapper.queryCount ( commentEntity.getOrderId (), commentEntity.getStuId (), commentEntity.getProductId (), commentEntity.getProductScore () );
        return integer;
    }

}
